package com.ftg.learn.smhtml.controller;

import com.ftg.learn.smhtml.pojo.About;
import com.ftg.learn.smhtml.service.AboutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/about")

public class AboutController {

    @Autowired
    AboutService cs;

    @GetMapping("/showabout")
    public Map<String, Object> showall(int page,int limit,String id ){
        System.out.println(page+"||"+limit+"||"+id);
        Map<String, Object> map=new HashMap<String, Object>();
        map.put("code", 0);
        map.put("msg", "1111");
        map.put("count", cs.getCount(id));
        map.put("data",  cs.showAll(id,page,limit));

        return map;

    }


    @PostMapping("/save")
    public int  save(About about) {
        return  cs.save(about);

    }


    @DeleteMapping("/delete/{id}")
    public int  delete(@PathVariable("id")  String id) {
        System.out.println(id);
        return  cs.delete(id);

    }

    @PostMapping("/update")
    public int update(About about) {
        return 	cs.update(about);

    }
    @PutMapping("/findone/{id}")
    public List<About> findone(@PathVariable("id") String id){
        return  cs.findone(id);//调




    }

}
